<?php
include("db/connect.php");
$sqlselectmaterial="select * from material ";
$sqlselectmaterial.="   group by mat_id";
$queryselectmaterial=mysql_query($sqlselectmaterial);
?>
<h1 style="text-align:center;font-size:24px">รายการสั่งซื้อวัตถุดิบ</h1>
<table width="100%" height="132" border="0">
<thead>
  <tr>
    <th width="15%">ชื่อสินค้า</th>
    <th width="9%">ราคา(หน่วย)</th>
    <th width="9%">หน่วย</th>
    <th width="7%">แก้ไข</th>
    <th width="6%">ลบ</th>
    <th width="10%">คลังวัตถุดิบ</th>
  </tr>
  </thead>
  <tbody>
  <?php 
  $countX=1;
  while($resultmaterial=mysql_fetch_array($queryselectmaterial)){
  ?>
  <tr valIn="<?php echo $countX?>">
    <td><?php echo $resultmaterial["mat_name"]?></td>
    <td><?php echo $resultmaterial["mat_price"]?></td>
    <td><?php echo $resultmaterial["mat_unit"]?></td>
    <td><a href="Javascript:ajaxmanage(2,<?php echo $resultmaterial["mat_id"];?>);">แก้ไข</a></td>
    <td><a href="Javascript:ajaxmanage(1,<?php echo $resultmaterial["mat_id"];?>);" onclick="return window.confirm('ต้องการลบใช่ไหม')">ลบ</a></td>
    <td><a href="#" onclick="storeMaterial(<?php echo $countX?>,<?php echo $resultmaterial["mat_id"];?>);">คลังวัตถุดิบ</a></td><?php // echo $resultmaterial["mat_id"];?>
  </tr>
  <?php 
    $countX++;
  }?>
  </tbody>
</table>
<span id="stock2" style="display:none"></span>
<script>
function storeMaterial(rows,matID){
	$("tbody > tr[valIn!="+rows+"]").remove();
	$.ajax({
		url:"list_stock2.php?mat_id="+matID,
		success: function(msg){
				$("#stock2").html(msg);
				$("#stock2").slideDown();
			}
		});

	}
</script>
<script>
$(function(){
$("#frmsearch").remove();
});

</script>
